<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%
	String path = request.getContextPath();
%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>其他资产信息</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body>
		<form id="cust_cst_ass_info_other_form">
             <div class="fieldset1 tabel_col tabel_col_s clearFix noBorder">
               
                <div class="fieldBox col_50">
                    <div class="label">所有权人</div>
                    <div class="field">
                        <input name="assOwner" id="assOwner" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">资产名称</div>
                    <div class="field">
                        <input name="assNm" id="assNm" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">市值(元)</div>
                    <div class="field">
                        <input name="value" id="value" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">收益(元)</div>
                    <div class="field">
                        <input name="revenue" id="revenue" type="text" class="ui-textbox" value="">
                    </div>
                </div>
                <div class="fieldBox col_50">
                    <div class="label">购买时间</div>
                    <div class="field">
                        <input name="purchDt" id="purchDt" type="text" class="ui-datepicker" value="">
                    </div>
                </div>
                <div class="fieldBox col_100">
                    <div class="label">备注</div>
                    <div class="field" style="width: 100%;">
                        <textarea name="assRem" id="assRem" rows="4" class="l-textarea" style="width:99%"></textarea>
                    </div>
                </div>
            </div>
            <!-- hide data -->
	        <div class="fieldBox col_100" style="display:none;">
	          <div class="field">
	              <input name=cstId id="cstId" type="text" class="ui-textbox" value="${cstId}">
	              <input name="caiId" id="caiId" type="text" class="ui-textbox" value="${caiId}">
	          </div>
	        </div>
            <div class="btnsBox">
                <span id="cust_cst_ass_info_other_form_add_btn_id" class="sq-button sq-button-round">保存</span>
                <span id="cust_cst_ass_info_other_form_cancel_btn_id" class="sq-button sq-button-round">取消</span>
            </div>
        </form>
	<script>
		$(function() {
		   $("#cust_cst_ass_info_other_form").ligerForm({
                validate: true
           });
		
		   
	        $("#cust_cst_ass_info_other_form_add_btn_id").click(function(event) {
	            var ligerForm = liger.get("cust_cst_ass_info_other_form");
	            if (!ligerForm.valid()) {
	                top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
	                return false; //验证不通过，不执行以下代码
	            }
	            var data = ligerForm.getData();
	            data["purchDt"] = $("#purchDt").val();
	            var caiId = $("#caiId").val();
	            var url = '<%=path%>/customer/cstassinfo/addOther.do';
	            if(caiId != ""){
	            	url = '<%=path%>/customer/cstassinfo/modifyOther.do';
	            	data["id"]= caiId;
	            }
	            //设置客户ID
	            var cstId = $("#cstId").val();
	            data["cstId"]= cstId;
	            var wait_dialog= top.$.ligerDialog.SQalert({
		            content: LogUtils.LOG_CMM_LOADING,
		            SQ_type: "waitting",
		            onClose: function () {
		            }
		        });
	            
	            $.ajax({
	        		type: 'post',
	        		dataType:'json',
	        		data:data,
	        		url: url,
	        		success:function(msg){
	        			wait_dialog.close();
	        			 if(msg.success == 1){
	        				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
	        				 parent.cstAssInfoOther.setParm("cstId",cstId);
	        				 parent.cstAssInfoOther.reload();
	        				 frameElement.dialog.close();
	        			 }else{
	        				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
	        			 }
	        		}
	        	});
	        });
	        
	        //取消
	        $("#cust_cst_ass_info_other_form_cancel_btn_id").click(function(event) {
	        	frameElement.dialog.close();
	        });
	        
	        initData();
		});
		
		function initData(){
			var caiId = $("#caiId").val();
	    	if(!caiId)return;
	    	 var wait_dialog= top.$.ligerDialog.SQalert({
		            content: LogUtils.LOG_CMM_LOADING,
		            SQ_type: "waitting",
		            onClose: function () {
		            }
		        });
	    	var _url = '<%=path%>/customer/cstassinfo/getOtherById.do';
	    	$.ajax({
	    		type: 'get',
	    		dataType:'json',
	    		data:{id:caiId},
	    		url: _url,
	    		success:function(msg){
	    			wait_dialog.close();
	    			 if(msg.success == 1){
	    				 setData(msg.data);//设置数据
	    			 }else{
	    				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
	    			 }
	    		}
	    	});
    	}
		
		//设置页面数据
	    function setData(data){
	    	var form = new liger.get("cust_cst_ass_info_other_form");
	    	var date = new Date(data.purchDt);
	    	var dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
    		$("#purchDt").val(dateStr);
	    	form.setData({
	    		assOwner:data.assOwner,
	    		assNm:data.assNm,
	    		value:data.value,
	    		revenue:data.revenue,
	    		assRem:data.assRem
	    	});
		};
	</script>

</body>
</html>